 <#include "../common/com.html"/> <@layout>

<!-- ace styles -->
<link rel="stylesheet" href="${ctx}/static/assets/css/ace.min.css" />
<link href='${ctx}/static/assets/css/select2.css' media='all'
	rel='stylesheet' type='text/css' />
<script src='${ctx}/static/assets/js/select2.min.js'
	type='text/javascript'></script>
<script src='${ctx}/static/assets/js/select2_locale_zh-CN.js'
	type='text/javascript'></script>
<script type="text/javascript">
	/**
	 * 新增
	 */
	function saveModel() {
		var card ='${(card)!}';
	
		var	url = '${ctx}/hyglZs/save';
		$('#form1').form('submit', {
			url : url,
			onSubmit : function() {
				return $(this).form('validate');
			},
			success : function(data) {
				var obj = eval("("+data+")");  ;
				var data =obj.id;
				var msg =obj.message;
				if(data=="0"){
					alert(msg);
				} else {
					alert(msg);
					window.location.href = '${ctx}/xskd?card='+data;
				}
			}
		});
	}
</script>
<div class="page-content" style="overflow: hidden">
	<div class="row-fluid">
		<form class="form-horizontal" id="form1" method="post">
		<input type="hidden" name="card" id="card" value="${(card)!}">
			<div class="span12">
				
				<div class="control-group">
					<label class="control-label">商品名称:</label>
					<div class="controls">
						<input id="wpid" name="wpid" type="text" onchange="getmc()"
							style="width: 200px; min-height: 24px;" /> <input id="wpmc"
							dataType="Require" msg="请选择商品" name="wpmc" type="hidden"
							style="min-height: 24px;" />
					</div>
				</div>


				<div class="control-group">
					<label class="control-label">服务种类:</label>
					<div class="controls">
						<input id="fulxid" name="fulxid" onclick="getfwmc();" type="text"
							style="min-height: 24px; width: 200px;" /> <input id="fulx"
							name="fulx" type="hidden" style="min-height: 24px;" />
					</div>
				</div>

			</div>
			<div class="span12 center">
				<a class="btn btn-info btn-small" onclick="saveModel()">确定 </a>
				&nbsp; &nbsp;&nbsp;&nbsp; <a
					class="btn btn-danger btn-small bigger-110"
					onclick="window.location.href=' ${ctx}/xskd/'">取消 </a>
			</div>
		</form>

	</div>
</div>

</body>

<script>
	/**
	 * 修改页面使用
	 */
	 jQuery(function($) {
		 $('#wpid').select2({
		        placeholder: "请输入查询商品名称或者编号",
		        minimumInputLength: 0,
		        ajax: {
		            url: "${ctx}/cgglWp/getWpxx",
		            dataType: 'json',
		            data: function (term, page) {
		                return {
		                    term: term,
		                    page_limit: 50,
		                    page: 0,
		                    apikey: "getwpxx"
		                };
		            },
		            results: function (data, page) {
		                return { results: data};
		            }

		        }
		    });

		    $('#fulxid').select2({
		        placeholder: "请输入服务类型",
		        minimumInputLength: 0,
		        ajax: {
		            url: "${ctx}/cgglWp/getFwzl",
		            dataType: 'json',
		            data: function (term, page) {
		                return {
		                    term: term,
		                    page_limit: 50,
		                    page: 0,
		                    apikey: "getFwzl"
		                };
		            },
		            results: function (data, page) {
		                return { results: data};
		            }

		        }
		    });
	
		   });
	  function getmc(){
	        var data = $("#wpid").select2("data");
	        var objs=JSONstringify(data);
	        var arr = eval('(' + objs + ')');
	        document.getElementById("wpmc").value=(arr['text']==undefined ) ? "" : arr['text'];
	    }
	    function getfwmc(){
	        var data = $("#fulxid").select2("data");
	        var objs=JSONstringify(data);
	        var arr = eval('(' + objs + ')');
	        document.getElementById("fulx").value=(arr['text']==undefined ) ? "" : arr['text'];
	    }
	    
	  //转json
	    function JSONstringify(Json){
	        if($.browser.msie){
	            if($.browser.version=="7.0"||$.browser.version=="6.0"){
	                var  result=jQuery.parseJSON(Json);
	            }else{
	                var result=JSON.stringify(Json);
	            }
	        }else{
	            var result=JSON.stringify(Json);
	        }
	        return result;
	    }
</script>
</@layout>
